#include <iostream> 
#include <algorithm>
#include <random>


using namespace std;


/**
 * \brief 打乱数组数据顺序
 * \param players 被洗牌的数据
 * \param times 洗牌次数
 */
void shuffle_test(vector<int>& players, int times);

void showVector(const vector<int>& players)
{
    auto len = players.size();
    auto c{ 0 };
    for (const auto& i : players)
    {
        cout << i << '\t';
        if ((++c) % 10 == 0)
        {
            cout << endl;
        }
    }
    cout << endl;
}

int main(int argc, char const* argv[])
{
    //生成100个数
    vector<int>  players;
    for (int i = 1; i <= 108; ++i)
    {
        players.emplace_back(i);
    }
    showVector(players);

    constexpr int times{ 5 }; // 洗牌次数
    shuffle_test(players, times); // 洗牌：进行times次 

    cout << "After shuffle:" << endl;
    showVector(players);


    return 0;
}

void shuffle_test(vector<int>& players, const int times)
{
    // 第三个参数是随机数生成器。
    // random_device， default_random_engine（std::mt19937），
    // minstd_rand（linear_congruential_engine） 

    for (int i = 0; i < times; i++)
    {
        ranges::shuffle(players,
            std::mt19937_64{ std::random_device{}() });
    }
}
